#include <stdio.h>

#define MAXSIZE 1000


typedef struct {
    int data[MAXSIZE];
    int top;
}Stack;

//初始化
void initStack(Stack *stack){
    //栈指针指向-1
    stack->top=-1;
}

//判断是否为空
int isEmpty(Stack *stack){
    return stack->top==-1;
}


//判断是否已满
int isFull(Stack *stack){
    return stack->top==MAXSIZE-1;
}

//入栈操作
//明确插入的栈,明确插入的值
int stackPush(Stack *stack,int value){
    //首先栈判断是否已满
    if(isFull(stack)){
        printf("Stack is full");
        return -1;
    }
    //上移指针
    stack->top++;
    //插入数据
    stack->data[stack->top]=value;
    return 0;
}

//出栈操作
int stackPop(Stack *stack){
    //首先判断是否为空
    if(isEmpty(stack)){
        printf("stack is empty");
        return -1;
    }
    //获取栈顶的值
    int value=stack->data[stack->top];
    //栈顶的指针下移一位
    stack->top--;
    return value;
}



int main(void){
    //新建栈
    Stack stack;
    //初始化栈
    initStack(&stack);
    printf("%d\n", isEmpty(&stack));
    stackPush(&stack,1);
    stackPush(&stack,2);
    stackPush(&stack,3);
    printf(stackPop(&stack));
}